/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.spectral.utilities.examples;


import com.compomics.spectral.utilities.dataprovider.prideXML.errors.enums.ConversionError;
import com.compomics.spectral.utilities.dataprovider.prideXML.errors.exceptions.XMLConversionException;
import com.compomics.spectral.utilities.dataprovider.prideXML.extractor.PrideXMLToMGFConverter;
import java.io.File;
import java.util.List;
import java.util.logging.Level;
import org.apache.log4j.Logger;
import uk.ac.ebi.pride.jaxb.xml.PrideXmlReader;

/**
 *
 * @author Kenneth
 */
public class ConversionExampleApp {

    private static PrideXMLToMGFConverter converter = PrideXMLToMGFConverter.getInstance();
    //private static File inputFile = new File("Z:/PRIDE-DATA/PRIDE-FTP-DOWNLOAD/PRIDE_Exp_Complete_Ac_24184.xml.gz");
    private static File inputFile = new File("V:/PRIDE-DATA/PRIDE-FTP-DOWNLOAD/PRIDE_Exp_Complete_Ac_2998.xml.gz");
    private static File outputFile = new File("C:/Users/Kenneth/Desktop/testjebeta.mgf");
    private static final Logger logger = Logger.getLogger(ConversionExampleApp.class);

    public static void main(String args[]) {
        converter.setBufferSize(1024 * 1024 * 8);
        try {
            converter.init(inputFile);
            converter.extractMGFFromPrideXML(inputFile, outputFile);
        } catch (XMLConversionException ex) {
            java.util.logging.Logger.getLogger(ConversionExampleApp.class.getName()).log(Level.SEVERE, null, ex);
        }
        String Filepath = inputFile.getAbsolutePath();

        //Errorreport
        List<ConversionError> errorList = converter.getErrorList();
        if (errorList.isEmpty() || errorList == null) {
            logger.debug("There were no errors during this conversion");
        }
        for (ConversionError anError : errorList) {
            logger.debug(anError.toString());
        }
        //getting a reader : 
        PrideXmlReader reader = converter.getPrideXmlReader();
        //clear the temp files :


        converter.clearTempFiles();

    }
}
